#pragma once
#include <iostream>
#include <QString>
#include <memory>
#include <QJsonObject>
#include <QJsonDocument>

class Protocol;
class ProtocolLogin;

using ProtocolPtr = std::shared_ptr<Protocol>;
using ProtocolLoginPtr = std::shared_ptr<ProtocolLogin>;


class Protocol
{
public:
    enum Type
    {
        UnKnown = 0,
        Login,
    };

    Protocol(Type type);

    virtual QString serialize() = 0;
    virtual void deserialize(const QString &) = 0;

    static bool isValidProtocolType(int value);

    virtual ~Protocol() {}

    Type _type;
};

class ProtocolLogin : public Protocol
{
public:

    ProtocolLogin();


    virtual QString serialize() override;
    virtual void deserialize(const QString & message) override;

    QString getUsername();
    QString getPassword();
    void setUsername(QString username);
    void setPassword(QString password);



private:
    QString username;
    QString password;
};

